package com.blog.cloud.auth.oauth;

import cn.hutool.core.util.EnumUtil;
import com.blog.cloud.auth.oauth.cache.AuthDefaultSource;
import com.blog.cloud.auth.oauth.config.AuthConfig;
import com.blog.cloud.auth.oauth.properties.AuthProperties;
import lombok.RequiredArgsConstructor;
import me.zhyd.oauth.cache.AuthStateCache;
import me.zhyd.oauth.request.*;

@RequiredArgsConstructor
public class AuthRequestFactory {

    private final AuthProperties properties;
    private final AuthStateCache authStateCache;

    private AuthRequest getDefaultRequest(String source) {
        AuthDefaultSource authDefaultSource;
        try {
            authDefaultSource = EnumUtil.fromString(AuthDefaultSource.class, source.toUpperCase());
        } catch (IllegalArgumentException var4) {
            return null;
        }

        AuthConfig config = this.properties.getType().get(authDefaultSource.name());
        if (config == null) {
            return null;
        } else {
            this.configureHttpConfig(authDefaultSource.name(), config, this.properties.getHttpConfig());
            switch (authDefaultSource) {
                case GITHUB:
                    return new AuthGithubRequest(config, this.authStateCache);
                case WEIBO:
                    return new AuthWeiboRequest(config, this.authStateCache);
                case GITEE:
                    return new AuthGiteeRequest(config, this.authStateCache);
                case DINGTALK:
                    return new AuthDingTalkRequest(config, this.authStateCache);
                case DINGTALK_ACCOUNT:
                    return new AuthDingTalkAccountRequest(config, this.authStateCache);
                case BAIDU:
                    return new AuthBaiduRequest(config, this.authStateCache);
                case CSDN:
                    return new AuthCsdnRequest(config, this.authStateCache);
                case CODING:
                    return new AuthCodingRequest(config, this.authStateCache);
                case OSCHINA:
                    return new AuthOschinaRequest(config, this.authStateCache);
                case ALIPAY:
                    return new AuthAlipayRequest(config, this.authStateCache);
                case QQ:
                    return new AuthQqRequest(config, this.authStateCache);
                case WECHAT_OPEN:
                    return new AuthWeChatOpenRequest(config, this.authStateCache);
                case WECHAT_MP:
                    return new AuthWeChatMpRequest(config, this.authStateCache);
                case WECHAT_ENTERPRISE:
                    return new AuthWeChatEnterpriseQrcodeRequest(config, this.authStateCache);
                case WECHAT_ENTERPRISE_WEB:
                    return new AuthWeChatEnterpriseWebRequest(config, this.authStateCache);
                case TAOBAO:
                    return new AuthTaobaoRequest(config, this.authStateCache);
                case GOOGLE:
                    return new AuthGoogleRequest(config, this.authStateCache);
                case FACEBOOK:
                    return new AuthFacebookRequest(config, this.authStateCache);
                case DOUYIN:
                    return new AuthDouyinRequest(config, this.authStateCache);
                case LINKEDIN:
                    return new AuthLinkedinRequest(config, this.authStateCache);
                case MICROSOFT:
                    return new AuthMicrosoftRequest(config, this.authStateCache);
                case MI:
                    return new AuthMiRequest(config, this.authStateCache);
                case TOUTIAO:
                    return new AuthToutiaoRequest(config, this.authStateCache);
                case TEAMBITION:
                    return new AuthTeambitionRequest(config, this.authStateCache);
                case RENREN:
                    return new AuthRenrenRequest(config, this.authStateCache);
                case PINTEREST:
                    return new AuthPinterestRequest(config, this.authStateCache);
                case STACK_OVERFLOW:
                    return new AuthStackOverflowRequest(config, this.authStateCache);
                case HUAWEI:
                    return new AuthHuaweiRequest(config, this.authStateCache);
                case GITLAB:
                    return new AuthGitlabRequest(config, this.authStateCache);
                case KUJIALE:
                    return new AuthKujialeRequest(config, this.authStateCache);
                case ELEME:
                    return new AuthElemeRequest(config, this.authStateCache);
                case MEITUAN:
                    return new AuthMeituanRequest(config, this.authStateCache);
                case TWITTER:
                    return new AuthTwitterRequest(config, this.authStateCache);
                case FEISHU:
                    return new AuthFeishuRequest(config, this.authStateCache);
                case JD:
                    return new AuthJdRequest(config, this.authStateCache);
                case ALIYUN:
                    return new AuthAliyunRequest(config, this.authStateCache);
                case XMLY:
                    return new AuthXmlyRequest(config, this.authStateCache);
                case AMAZON:
                    return new AuthAmazonRequest(config, this.authStateCache);
                case SLACK:
                    return new AuthSlackRequest(config, this.authStateCache);
                case LINE:
                    return new AuthLineRequest(config, this.authStateCache);
                case OKTA:
                    return new AuthOktaRequest(config, this.authStateCache);
                default:
                    return null;
            }
        }
    }
}
